mui.init()
terminalwork = new Vue({
	el: "#toolCheckList",
	data: {
		currentUser:'', // 当前用户
		currentPage:1, // 当前页
		toolKeyword:'', // 关键字
		toolList:[], // 列表数组
	},
	components:{
	},
	created: function() {
		localStorage.setItem("toolCheckList",'')
		this.currentUser = JSON.parse(localStorage.getItem("neiosUser"))
		this.queryToolList(this.currentPage)
	},
	methods: {
		// 隐藏操作按钮
		hideOperBtn () {
			$('.terminalwork-list-operbtn').css('width','0');
		},
		// keyword查询
		toolKeywordChange () {
			this.queryToolList(1)
		},
		// 查询列表
		queryToolList (current) {
			this.hideOperBtn()
			let _this = this
			let param = {
				current:current,
				pageSize: 999,
				currentUser:_this.currentUser,// 用户信息
				workType:'0207',
				searchType: "keyWord",
				searchParams: {
					role: _this.currentUser.roles,
					stationCode: _this.currentUser.stationNewCode
				},
				
			}
			mui.neiosRequst.httpRequst('/app/currentEntry/toolCheck/getToolsCheckByPage', param,
				function(data) {
					
					if (data.code == '0') {
						_this.toolList = data.data.records
					} else {
						_this.toolList = []
						mui.toast('查询列表失败，请稍后重试！')
					}
				},
				function() {
					_this.toolList = []
					mui.toast('查询列表失败，请稍后重试！')
				}
			);
		},
		// 删除批次及关联数据
		deleteToolsCheck (toolsCheckId) {
			let _this = this;
			let params = {
				toolsCheckId: toolsCheckId,
				currentUser: _this.currentUser
			};
			var btnArray = ['取消', '确定'];
			mui.confirm('是否确认删除？', '提示', btnArray, function(e) {
			    if (e.index == 1) {
					mui.neiosRequst.httpRequst('/app/currentEntry/toolCheck/deleteToolsCheckById', params,
						function(data) {
							if (data.code == '0') {
								_this.queryToolList(1)
								mui.toast('删除成功！')
							} else {
								mui.toast('删除失败，请稍后重试！')
							}
						},
						function() {
							mui.toast('删除失败，请稍后重试！')
						}
					);
			    } else {
					return false
				}
			})
		},
		// 修改跳转到修改页面
		toCheckAdd (toolsCheckId, flag) {
			let param = {
				addOrUpdate: flag,
				toolsCheckId: toolsCheckId,
				current: this.pageIndex,
				alwinType: 0,
				dailyOrRegular: 'daily',
			}
			localStorage.setItem("toolCheckList",JSON.stringify(param))
			mui.openWindow({
				url: 'toolCheckAdd.html',
				id: 'toolCheckAdd.html',
				extras: {},
				waiting: {
					autoShow: false
				}
			});
		},
		//跳转到新增页面
		add() {
			let param = {
				addOrUpdate: 'add',
				current: this.pageIndex,
				alwinType: 0,
				dailyOrRegular: 'daily'
			}
			localStorage.setItem("toolCheckList",JSON.stringify(param))
			mui.openWindow({
				url: 'toolCheckAdd.html',
				id: 'toolCheckAdd.html',
				extras: {},
				waiting: {
					autoShow: false
				}
			});
		},
	}
});
// 显示操作按钮
function showOperBtn (el) {
	$('.terminalwork-list-operbtn').css('width','0');
	$(el).next().css('width','39vw');
}
mui.plusReady(function () {
	window.addEventListener('isRefresh',function(){
		window.location.reload()
	})
})
mui.init({
	// pullRefresh: {
	// 	container: "#list", //待刷新区域标识，querySelector能定位的css选择器均可，比如：id、.class等
	// 	up: { //上拉加载
	// 		height: 50, //可选.默认50.触发上拉加载拖动距离
	// 		auto: false, //可选,默认false.自动上拉加载一次
	// 		contentrefresh: "正在加载...", //可选，正在加载状态时，上拉加载控件上显示的标题内容
	// 		contentnomore: '没有更多数据了', //可选，请求完毕若没有更多数据时显示的提醒内容；
	// 		style:'circle',
	// 		callback: async function() { //必选，刷新函数，根据具体业务来编写，比如通过ajax从服务器获取新数据；
				
	// 			terminalwork.queryToolList()
	// 		}
	// 	}
	// },
}); 